# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

_realname=cloog
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.18.1
pkgrel=3
pkgdesc="Library that generates loops for scanning polyhedra"
arch=('any')
url="https://www.bastoul.net/cloog/"
license=('GPL')
depends=("${MINGW_PACKAGE_PREFIX}-isl")
makedepends=("${MINGW_PACKAGE_PREFIX}-isl")
options=('staticlibs')
source=(https://www.bastoul.net/cloog/pages/download/${_realname}-${pkgver}.tar.gz
        'cloog-0.18.1-no-undefined.patch'
        'cloog-0.18.1-isl-use-documented-functions.patch'
        'cloog-0.18.1-isl-use-isl_val.patch')
sha256sums=('02500a4edd14875f94fe84cbeda4290425cb0c1c2474c6f75d75a303d64b4196'
            '70a9ba72be85a9982e99e3c093c0a2de563120a6bddde57c8332355e8a622bc0'
            '128fa2b4d6e281a8713f141052a6ca4e0bec217cac2445d6f8bd388bb451f632'
            '0e198323f73c6a7dc68c634632a9c6f9bca5ceac878f680e31d21cedd5ef2b20')

prepare() {
  cd "$srcdir/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/cloog-0.18.1-no-undefined.patch
  patch -p1 -i ${srcdir}/cloog-0.18.1-isl-use-documented-functions.patch
  patch -p1 -i ${srcdir}/cloog-0.18.1-isl-use-isl_val.patch

  autoreconf -fi
}

build() {
  cd $srcdir/${_realname}-${pkgver}
  ./configure --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --enable-static \
    --disable-shared \
    --with-isl=system \
    --with-bits=gmp \
    --with-isl-prefix=${MINGW_PREFIX} \
    --with-gmp-prefix=${MINGW_PREFIX} \
    --program-suffix=-isl
  make
}

check() {
  cd $srcdir/${_realname}-${pkgver}
  make check
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  rm -f ${pkgdir}${MINGW_PREFIX}/bin/*.exe
}
